Объединение различных PDF-файлов на одну PDF-страницу и создание образца буклета.C#

Место общения программистов C#
Гость
Объединение различных PDF-файлов на одну PDF-страницу и создание образца буклета.

Сообщение Гость »

Код: Выделить всё

using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace CutAndPaste
{
class Program
{
public static readonly string SRC = Environment.CurrentDirectory + "\\pdfs\\2.pdf";
public static readonly string SRC2 = Environment.CurrentDirectory + "\\pdfs\\3.pdf";
public static readonly string DEST = Environment.CurrentDirectory + "\\output.pdf";

static void Main(string[] args)
{
MergePDFs(DEST, SRC, SRC2);
Console.WriteLine("PDF'ler başarıyla birleştirildi.");
}

static void MergePDFs(string destPath, params string[] sourcePaths)
{
using (FileStream fs = new FileStream(destPath, FileMode.Create, FileAccess.Write, FileShare.None))
using (Document doc = new Document())
using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
{
doc.Open();
PdfContentByte cb = writer.DirectContent;

foreach (string sourcePath in sourcePaths)
{
using (PdfReader reader = new PdfReader(sourcePath))
{
for (int pageNumber = 1; pageNumber 

Подробнее здесь: [url]https://stackoverflow.com/questions/78163904/combining-different-pdf-files-onto-a-single-pdf-page-creating-a-sample-booklet[/url]

Вернуться в «C#»