Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
PDF → one long image, version 1.10.0
KnifeLemoncbd6f47f6696
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 070f627f..f08810d1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,15 @@ version it publishes under "What's Changed" in the GitHub release notes, above tAdd a `## <version>` section before tagging a release. Write what someone using Filee notices: what's new, where tofind it, what it does and doesn't do.+## 1.10.0++### New++- **PDF → one long image** (issue #50). A multi-page PDF becomes a single tall image with the pages one under+ another, e.g. to post a whole document at once. Use **Long image** on the PDF donut (PNG), or tick "Stack the pages+ into one tall image" in any image preset. Pages of different widths are centred; a result taller than the format+ stores (JPG 65,500 px, WebP 16,383 px) or very large is scaled down to fit. TIFF and GIF keep one page per frame.+## 1.9.0### Newdiff --git a/Directory.Build.props b/Directory.Build.propsindex 57c2fe3c..56123de2 100644--- a/Directory.Build.props+++ b/Directory.Build.props@@ -14,7 +14,7 @@parameters of a member is fine (CS1573). --><NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>- <Version>1.9.0</Version>+ <Version>1.10.0</Version><Product>Filee</Product><Authors>Filee contributors</Authors><Copyright>Copyright (c) Filee contributors</Copyright>diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex fa298052..2d433f4b 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -104,6 +104,7 @@"preset.grayscale": "Grayscale","preset.merge_pdf": "Merge PDF","preset.split_pdf": "Split PDF",+ "preset.long_image": "Long image","preset.extract": "Extract","preset.zip_all": "One ZIP",@@ -304,6 +305,8 @@"presets.page_range": "Pages","presets.page_range_hint": "All pages, or e.g. 1-3, 5","presets.split": "One file per page",+ "presets.combine_pages_hint": "All pages one under another in a single image, e.g. to post a document in one piece. Very long results are scaled down to what the format stores (JPG 65,500 px, WebP 16,383 px tall).",+ "presets.combine_pages": "Stack the pages into one tall image (when a PDF is converted)","presets.group.document": "Documents","presets.pdfa": "PDF/A (archival)","presets.target_folder": "Folder (extract archives)",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex 803638fe..8b6e9282 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -104,6 +104,7 @@"preset.grayscale": "흑백","preset.merge_pdf": "PDF 병합","preset.split_pdf": "PDF 분할",+ "preset.long_image": "긴 이미지","preset.extract": "압축 풀기","preset.zip_all": "ZIP 하나로",@@ -304,6 +305,8 @@"presets.page_range": "페이지","presets.page_range_hint": "전체, 또는 예: 1-3, 5","presets.split": "페이지마다 파일 하나",+ "presets.combine_pages_hint": "여러 페이지를 위아래로 붙여 이미지 한 장으로 만들어요. 문서를 한 번에 올릴 때 좋아요. 너무 길면 형식이 저장할 수 있는 높이에 맞춰 줄여요(JPG 65,500px, WebP 16,383px).",+ "presets.combine_pages": "모든 페이지를 세로로 이어 한 장으로 (PDF를 변환할 때)","presets.group.document": "문서","presets.pdfa": "PDF/A (장기 보존용)","presets.target_folder": "폴더 (압축 풀기)",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 4f27e220..0a6b428c 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -104,6 +104,7 @@"preset.grayscale": "灰度","preset.merge_pdf": "合并 PDF","preset.split_pdf": "拆分 PDF",+ "preset.long_image": "长图","preset.extract": "解压","preset.zip_all": "打包成一个 ZIP",@@ -304,6 +305,8 @@"presets.page_range": "页面","presets.page_range_hint": "全部,或如 1-3, 5","presets.split": "每页一个文件",+ "presets.combine_pages_hint": "所有页面上下相接,生成一张图片,适合一次性发布整份文档。过长时会缩小到该格式能保存的高度(JPG 65,500 像素,WebP 16,383 像素)。",+ "presets.combine_pages": "把所有页面上下拼成一张长图(转换 PDF 时)","presets.group.document": "文档","presets.pdfa": "PDF/A(长期存档)","presets.target_folder": "文件夹(解压缩)",diff --git a/src/Filee.App/ViewModels/PresetEditorViewModel.cs b/src/Filee.App/ViewModels/PresetEditorViewModel.csindex 25a3ecc4..c19fc875 100644--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs@@ -106,6 +106,7 @@ public sealed partial class PresetEditorViewModel : ObservableObject_renderDpi = _edit.Pdf.RenderDpi;_pageRange = _edit.Pdf.PageRange;_splitPages = _edit.Pdf.SplitPages;+ _combinePages = _edit.Pdf.CombinePages;_pdfA = _edit.Document.PdfA;_subfolderName = _edit.Output.SubfolderName;_customFolder = _edit.Output.CustomFolder;@@ -134,7 +135,7 @@ public sealed partial class PresetEditorViewModel : ObservableObject[ObservableProperty][NotifyPropertyChangedFor(nameof(ShowImage), nameof(ShowQuality), nameof(ShowTiff), nameof(ShowMultiPageTiff), nameof(ShowWebp), nameof(ShowIco),- nameof(ShowPdf), nameof(ShowPdfBuild), nameof(ShowDocument), nameof(ShowPdfSplit),+ nameof(ShowPdf), nameof(ShowPdfBuild), nameof(ShowDocument), nameof(ShowPdfSplit), nameof(ShowPdfCombine),nameof(ShowMedia), nameof(ShowMediaQuality), nameof(ShowMaxHeight), nameof(ShowAudioBitrate), nameof(ShowRemoveAudio),nameof(ShowAudioChannels), nameof(ShowWav),nameof(ShowArchive), nameof(ShowArchiveOptions), nameof(ShowExtractNote))]@@ -188,6 +189,9 @@ public sealed partial class PresetEditorViewModel : ObservableObject[ObservableProperty] private int _renderDpi;[ObservableProperty] private string _pageRange;[ObservableProperty] private bool _splitPages;++ /// <summary>PDF → image: one tall image of all pages.</summary>+ [ObservableProperty] private bool _combinePages;[ObservableProperty] private bool _pdfA;[ObservableProperty] private string _subfolderName;[ObservableProperty] private string _customFolder;@@ -220,6 +224,9 @@ public sealed partial class PresetEditorViewModel : ObservableObjectpublic bool ShowPdf => TargetCategory is not (FormatCategory.Video or FormatCategory.Audio or FormatCategory.Archive or FormatCategory.Font);public bool ShowPdfBuild => TargetId == "pdf";public bool ShowPdfSplit => TargetId == "pdf";++ /// <summary>PDF → a single-image format: the pages can be stacked into one tall image (TIFF and GIF keep pages).</summary>+ public bool ShowPdfCombine => TargetCategory == FormatCategory.Image && TargetId is not ("tiff" or "gif" or "ico" or "icns" or "svg" or "pdf");public bool ShowDocument => TargetId == "pdf";public bool ShowMedia => ShowMediaQuality || ShowMaxHeight || ShowRemoveAudio || ShowAudioChannels;/// <summary>Mono / stereo for every audio target but AMR, which is mono by definition.</summary>@@ -282,6 +289,7 @@ public sealed partial class PresetEditorViewModel : ObservableObjectpdf.RenderDpi = Math.Clamp(RenderDpi, 36, 1200);pdf.PageRange = PageRange.Trim();pdf.SplitPages = SplitPages;+ pdf.CombinePages = CombinePages;_original.Document.PdfA = PdfA;var media = _original.Media;diff --git a/src/Filee.App/Views/PresetEditorView.axaml b/src/Filee.App/Views/PresetEditorView.axamlindex daa06520..646a5840 100644--- a/src/Filee.App/Views/PresetEditorView.axaml+++ b/src/Filee.App/Views/PresetEditorView.axaml@@ -151,6 +151,10 @@<TextBlock Classes="h2" Text="{DynamicResource presets.group.pdf}" /><CheckBox Content="{DynamicResource presets.merge}" IsChecked="{Binding Merge}" IsVisible="{Binding ShowPdfBuild}" /><CheckBox Content="{DynamicResource presets.split}" IsChecked="{Binding SplitPages}" IsVisible="{Binding ShowPdfSplit}" />+ <StackPanel Spacing="2" IsVisible="{Binding ShowPdfCombine}">+ <CheckBox Content="{DynamicResource presets.combine_pages}" IsChecked="{Binding CombinePages}" />+ <TextBlock Classes="caption" TextWrapping="Wrap" Margin="28,0,0,0" Text="{DynamicResource presets.combine_pages_hint}" />+ </StackPanel><Grid ColumnDefinitions="*,12,*" IsVisible="{Binding ShowPdfBuild}"><StackPanel><TextBlock Classes="label" Text="{DynamicResource presets.page_size}" />diff --git a/src/Filee.Core/Presets/BuiltInData.cs b/src/Filee.Core/Presets/BuiltInData.csindex 63ce05af..292c4574 100644--- a/src/Filee.Core/Presets/BuiltInData.cs+++ b/src/Filee.Core/Presets/BuiltInData.cs@@ -49,6 +49,11 @@ public static class BuiltInDataPdf = { MergeIntoSingle = true }, Output = { FileNamePattern = "{name}_merged" },},new()+ {+ Id = "pdf-long-image", NameKey = "preset.long_image", TargetFormat = "png",+ Pdf = { CombinePages = true }, Output = { FileNamePattern = "{name}_long" },+ },+ new(){Id = "pdf-split", NameKey = "preset.split_pdf", TargetFormat = "pdf",Pdf = { SplitPages = true }, Output = { Location = OutputLocation.Subfolder, SubfolderName = "{name}" },@@ -167,7 +172,7 @@ public static class BuiltInData{Id = "pdf", NameKey = "profile.pdf",Extensions = ["pdf"],- PresetIds = ["to-png", "to-jpg", "to-docx", "to-txt", "to-md", "to-epub", "to-hwpx", "to-hwp", "to-tiff", "pdf-split", "merge-pdf"],+ PresetIds = ["to-png", "to-jpg", "pdf-long-image", "to-docx", "to-txt", "to-md", "to-epub", "to-hwpx", "to-hwp", "to-tiff", "pdf-split", "merge-pdf"],},new(){diff --git a/src/Filee.Core/Presets/Preset.cs b/src/Filee.Core/Presets/Preset.csindex 6650e33a..30dac1b5 100644--- a/src/Filee.Core/Presets/Preset.cs+++ b/src/Filee.Core/Presets/Preset.cs@@ -162,6 +162,9 @@ public sealed class PdfOptions/// <summary>For PDF → PDF: write every page as its own file.</summary>public bool SplitPages { get; set; }+ /// <summary>For PDF → image: stack the pages into one tall image instead of one image per page.</summary>+ public bool CombinePages { get; set; }+public PdfOptions Clone() => (PdfOptions)MemberwiseClone();}diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.csindex 0d467d49..ae84ebea 100644--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@ -50,7 +50,7 @@ public sealed class DonutSettingspublic sealed class AppSettings{/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>- public const int CurrentSchemaVersion = 8;+ public const int CurrentSchemaVersion = 9;public int SchemaVersion { get; set; } = CurrentSchemaVersion;diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.csindex 92f261ec..2deba682 100644--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@ -338,6 +338,17 @@ internal static class SettingsMigrationschanged = true;}}++ // v9: PDF → one tall image (all pages stacked), on the PDF donut after JPG (issue #50).+ if (from < 9)+ {+ if (presets.All(p => p.Id != "pdf-long-image"))+ {+ presets.Add(BuiltInData.CreatePresets().Single(p => p.Id == "pdf-long-image"));+ changed = true;+ }+ changed |= Offer(presets, profiles, "pdf", "pdf-long-image", "to-jpg");+ }return changed;}diff --git a/src/Filee.Engines/Pdf/PdfiumConverter.cs b/src/Filee.Engines/Pdf/PdfiumConverter.csindex 3eff7823..ade83426 100644--- a/src/Filee.Engines/Pdf/PdfiumConverter.cs+++ b/src/Filee.Engines/Pdf/PdfiumConverter.cs@@ -1,4 +1,5 @@-// Renders PDF pages to raster images with PDFium (via PDFtoImage, MIT / PDFium BSD-3).+// Renders PDF pages to raster images with PDFium (via PDFtoImage, MIT / PDFium BSD-3): one image per page, one+// multi-page TIFF or GIF, or (PdfOptions.CombinePages) the pages stacked into one tall image.using Filee.Core.Conversion;using Filee.Engines.Infrastructure;@@ -18,6 +19,9 @@ public sealed class PdfiumConverter : IConverter{private static readonly HashSet<string> MultiPageTargets = ["tiff", "gif"];+ /// <summary>A tall image beyond this many pixels is scaled down (a 300-page PDF at 300 dpi would need gigabytes).</summary>+ internal const long MaxStackedPixels = 200_000_000;+public string Id => "pdfium";public string DisplayName => "PDFium";@@ -40,6 +44,7 @@ public sealed class PdfiumConverter : IConvertervar written = new List<string>();var collected = new List<IMagickImage<byte>>();var (format, extension) = ImageEncoder.OutputFormat(step.To, step.Preset.Image);+ var stack = step.Preset.Pdf.CombinePages && pages.Count > 1 && !MultiPageTargets.Contains(step.To);try{@@ -51,6 +56,12 @@ public sealed class PdfiumConverter : IConverterindex++;var frame = ToMagick(bitmap, dpi);+ if (stack)+ {+ collected.Add(frame); // stacked after the loop; the image options apply to the tall image+ progress?.Report((double)index / pages.Count * 0.8);+ continue;+ }ImageEncoder.ApplyOptions(frame, step.Preset.Image, step.To);if (MultiPageTargets.Contains(step.To))@@ -72,8 +83,20 @@ public sealed class PdfiumConverter : IConverterprogress?.Report((double)index / pages.Count);}- if (collected.Count > 0)+ if (stack)+ {+ using var tall = Stack(collected, step.To);+ ImageEncoder.ApplyOptions(tall, step.Preset.Image, step.To);+ if (step.Output.Allocate(extension, null) is { } path)+ {+ tall.Write(path, format);+ written.Add(path);+ }+ }+ else if (collected.Count > 0)+ {written.AddRange(ImageEncoder.Write(collected, step.To, step.Output, step.Preset.Image));+ }}finally{@@ -83,6 +106,41 @@ public sealed class PdfiumConverter : IConverterreturn written;}, cancellationToken);+ /// <summary>+ /// The pages one under another, centred on a white strip as wide as the widest page. Scaled down when the result+ /// would be taller than the format stores (JPEG 65,500 px, WebP 16,383 px) or larger than+ /// <see cref="MaxStackedPixels"/>.+ /// </summary>+ internal static IMagickImage<byte> Stack(IReadOnlyList<IMagickImage<byte>> pages, string target)+ {+ double width = pages.Max(p => p.Width);+ double height = pages.Sum(p => (double)p.Height);+ var scale = Math.Min(1, Math.Min(MaxHeight(target) / height, Math.Sqrt(MaxStackedPixels / (width * height))));+ var stripWidth = (uint)Math.Max(1, Math.Floor(width * scale));+ using var strip = new MagickImageCollection();+ foreach (var page in pages)+ {+ var copy = page.Clone();+ if (scale < 1)+ copy.Resize((uint)Math.Max(1, Math.Floor(copy.Width * scale)), (uint)Math.Max(1, Math.Floor(copy.Height * scale)));+ copy.BackgroundColor = MagickColors.White;+ copy.Extent(stripWidth, copy.Height, Gravity.North);+ strip.Add(copy);+ }+ var tall = strip.AppendVertically();+ tall.Density = pages[0].Density;+ return tall;+ }++ /// <summary>The tallest image a format stores; PNG, TIFF and the rest take more than a stack ever needs.</summary>+ internal static double MaxHeight(string target) => target switch+ {+ "jpg" or "jpeg" => 65_500,+ "webp" => 16_383,+ "avif" or "heic" => 16_384,+ _ => 1_000_000,+ };+private static MagickImage ToMagick(SKBitmap bitmap, int dpi){using (bitmap)diff --git a/tests/Filee.Core.Tests/UserDataStoreTests.cs b/tests/Filee.Core.Tests/UserDataStoreTests.csindex 2806b6c5..6ee1afee 100644--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs@@ -173,6 +173,24 @@ public class UserDataStoreTestsAssert.False(SettingsMigrations.ApplyToLibrary(6, presets, profiles)); // once only}+ [Fact]+ public void Version_8_libraries_get_the_long_image_preset_after_jpg()+ {+ // As written by 1.9.0: no "Long image" preset, and the PDF donut without it.+ var presets = BuiltInData.CreatePresets();+ presets.RemoveAll(p => p.Id == "pdf-long-image");+ var profiles = BuiltInData.CreateProfiles();+ var pdf = profiles.Single(p => p.Id == "pdf");+ pdf.PresetIds.Remove("pdf-long-image");++ Assert.True(SettingsMigrations.ApplyToLibrary(8, presets, profiles));++ var longImage = presets.Single(p => p.Id == "pdf-long-image");+ Assert.True(longImage.Pdf.CombinePages);+ Assert.Equal(pdf.PresetIds.IndexOf("to-jpg") + 1, pdf.PresetIds.IndexOf("pdf-long-image"));+ Assert.False(SettingsMigrations.ApplyToLibrary(8, presets, profiles)); // once only+ }+[Fact]public void Catalog_migration_ignores_extensions_checked_on_mixed_profiles(){diff --git a/tests/Filee.Engines.Tests/ImageAndPdfTests.cs b/tests/Filee.Engines.Tests/ImageAndPdfTests.csindex 5d9910c5..a68ced16 100644--- a/tests/Filee.Engines.Tests/ImageAndPdfTests.cs+++ b/tests/Filee.Engines.Tests/ImageAndPdfTests.cs@@ -218,6 +218,43 @@ public class ImageAndPdfTests(EngineFixture fx) : IClassFixture<EngineFixture>Assert.Equal(3, pages.Count);}+ [Fact]+ public async Task Pdf_pages_stack_into_one_tall_image()+ {+ // Issue #50: an 8-page PDF gave 8 pictures; "Long image" gives one with the pages one under another.+ var dir = fx.NewFolder();+ var pdf = (await fx.ConvertAsync([EngineFixture.MakeMultiPageTiff(dir, 3)], new Preset { TargetFormat = "pdf" })).Outputs.Single();+ using var firstPage = new MagickImage((await fx.ConvertAsync([pdf], new Preset { TargetFormat = "png", Pdf = { RenderDpi = 72, PageRange = "1" } })).Outputs.Single());++ var job = await fx.ConvertAsync([pdf], new Preset { TargetFormat = "png", Pdf = { RenderDpi = 72, CombinePages = true }, Output = { FileNamePattern = "{name}_long" } });++ AssertDone(job);+ Assert.Equal("pages_long.png", Path.GetFileName(job.Outputs.Single()));+ using var tall = new MagickImage(job.Outputs.Single());+ Assert.Equal(firstPage.Width, tall.Width);+ Assert.Equal(firstPage.Height * 3, tall.Height);+ }++ [Theory]+ [InlineData("jpg", 65_500)]+ [InlineData("webp", 16_383)]+ public void A_stack_taller_than_the_format_stores_is_scaled_down(string target, int limit)+ {+ // 40 A4 pages at 300 dpi: about 140,000 px tall.+ var pages = Enumerable.Range(0, 40).Select(_ => (IMagickImage<byte>)new MagickImage(MagickColors.SkyBlue, 2480, 3508)).ToList();+ try+ {+ using var tall = Filee.Engines.Pdf.PdfiumConverter.Stack(pages, target);+ Assert.True(tall.Height <= limit, $"{tall.Height} px");+ Assert.True((long)tall.Width * tall.Height <= Filee.Engines.Pdf.PdfiumConverter.MaxStackedPixels);+ Assert.InRange(tall.Width / (double)tall.Height, 2480 / (3508.0 * 40) * 0.95, 2480 / (3508.0 * 40) * 1.05); // pages keep their shape+ }+ finally+ {+ pages.ForEach(p => p.Dispose());+ }+ }+[Fact]public async Task Merge_images_into_one_pdf(){