Process for the combined production of hydrogen and carbon dioxide from a mixture of hydrocarbons comprising at least the following stages: - a stage (a) of reforming or of partial oxidation of the mixture of hydrocarbons in order to obtain a synthesis gas containing at least hydrogen, carbon monoxide, carbon dioxide, methane, steam and at least one of the following hydrocarbons: ethane, propane, ethylene, propene, benzene or methanol, - a stage (b) of cooling the synthesis gas with recovery of the available heat, - a stage (c) of conversion (shift) reaction of all or part of the cooled synthesis gas in order to oxidize most of the carbon monoxide to give carbon dioxide with corresponding production of hydrogen and of a synthesis gas enriched in H 2 and CO 2 and containing impurities, including at least one of the following hydrocarbons: ethane, propane, ethylene, propene, benzene or methanol, - a stage (d) of cooling the synthesis gas enriched in H 2 and CO 2 resulting from stage (c) with removal of the condensed water, - an optional stage (e) of additional drying of the cooled synthesis gas in order to obtain a dry synthesis gas, - a stage (f) of separation of the optionally dry synthesis gas in a pressure swing adsorption (PSA H 2) unit, making it possible to obtain a high-pressure H 2 stream enriched in hydrogen and a PSA residual gas stream depleted in hydrogen containing at least carbon dioxide, hydrogen and at least one of the following hydrocarbons: ethane, propane, ethylene or propene, - an optional stage (g) of drying the residual gas stream, - a stage (h) of separation by permeation of the stream of the residual gas in a first membrane system in order to obtain a permeate depleted in at least one of the following hydrocarbons: ethane, propane, ethylene, propene, benzene or methanol and enriched in carbon dioxide and in hydrogen, as well as a non-permeate enriched in at least one of the following hydrocarbons: ethane, propane, ethylene or propene and depleted in carbon dioxide and in hydrogen, the permeate having a carbon dioxide partial pressure of greater than 519 kPa, preferably of greater than 1000 kPa, - a stage (i) of partial condensation and/or of distillation of the said permeate in order to obtain a liquid stream rich in CO 2 and a residual gas stream, and in which this residual gas stream is sent to the pressure swing adsorption unit. - a stage (a) of reforming or of partial oxidation of the mixture of hydrocarbons in order to obtain a synthesis gas containing at least hydrogen, carbon monoxide, carbon dioxide, methane, steam and at least one of the following hydrocarbons: ethane, propane, ethylene, propene, benzene or methanol, - a stage (b) of cooling the synthesis gas with recovery of the available heat, - a stage (c) of conversion (shift) reaction of all or part of the cooled synthesis gas in order to oxidize most of the carbon monoxide to give carbon dioxide with corresponding production of hydrogen and of a synthesis gas enriched in H 2 and CO 2 and containing impurities, including at least one of the following hydrocarbons: ethane, propane, ethylene, propene, benzene or methanol, - a stage (d) of cooling the synthesis gas enriched in H 2 and CO 2 resulting from stage (c) with removal of the condensed water, - an optional stage (e) of additional drying of the cooled synthesis gas in order to obtain a dry synthesis gas, - a stage (f) of separation of the optionally dry synthesis gas in a pressure swing adsorption (PSA H 2) unit, making it possible to obtain a high-pressure H 2 stream enriched in hydrogen and a PSA residual gas stream depleted in hydrogen containing at least carbon dioxide, hydrogen and at least one of the following hydrocarbons: ethane, propane, ethylene or propene, - an optional stage (g) of drying the residual gas stream, - a stage (h) of separation by permeation of the stream of the residual gas in a first membrane system in order to obtain a permeate depleted in at least one of the following hydrocarbons: ethane, propane, ethylene, propene, benzene or methanol and enriched in carbon dioxide and in hydrogen, as well as a non-permeate enriched in at least one of the following hydrocarbons: ethane, propane, ethylene or propene and depleted in carbon dioxide and in hydrogen, the permeate having a carbon dioxide partial pressure of greater than 519 kPa, preferably of greater than 1000 kPa, - a stage (i) of partial condensation and/or of distillation of the said permeate in order to obtain a liquid stream rich in CO 2 and a residual gas stream, and