благодарит за потраченное время, чтобы прочитать мою странную проблему с PDFSharp.PDFSharp сокращает ландшафтные страницы с помощью C# и WPF
Я использую PDFSharp Library Version 1.50.4000.0 (я обновляюсь с версии 1.3.2 и имею такую же проблему) в то время, чтобы защитить файл PDF с паролем.
Программа работает очень хорошо с портретными документами, но иногда у меня есть документы со смешанными ориентациями.
Но все время, когда страница пейзажа находится в документе, страница вырезана.
Код для справки:
PdfDocument document = PdfReader.Open(System.IO.Path.Combine("H:/Bloq1/", file.Name), "PasswordHere");
PdfSecuritySettings securitySettings = document.SecuritySettings;
securitySettings.OwnerPassword = "PasswordHere";
securitySettings.PermitAccessibilityExtractContent = false;
securitySettings.PermitAnnotations = false;
securitySettings.PermitAssembleDocument = false;
securitySettings.PermitExtractContent = false;
securitySettings.PermitFormsFill = true;
securitySettings.PermitFullQualityPrint = true;
securitySettings.PermitModifyDocument = false;
securitySettings.PermitPrint = true;
document.Save(System.IO.Path.Combine("H:/Bloq1/", file.Name));
tbx.Text = "Complete";
tbx.Background = Brushes.ForestGreen;
Спасибо заранее за ваше время чтения или ответа на этот вопрос = D
**************** ************* решаемые ************************************ *********
переключается на iTextSharp и протестировать пару документов и работает довольно хорошо, я поделюсь кодом для справки:
private void Button_Full(object sender, RoutedEventArgs e)//PROTEGE PDF PERMITIENDO IMPRESION
{
string Password = "password";
DirectoryInfo dir = new DirectoryInfo("H:/Bloq1/");
if(dir.GetFiles("*.pdf").Length ==0)
{
MessageBox.Show("There are no files in the default directory", "No Files", MessageBoxButton.OK, MessageBoxImage.Warning);
tbx.Background = Brushes.OrangeRed;
tbx.Text = "No Files Found";
}
else
{
tbx.Background = Brushes.White;
tbx.Text = "Protecting....";
foreach (FileInfo file in dir.GetFiles("*.pdf"))
{
try
{
string InputFile = System.IO.Path.Combine("H:/Bloq1/", file.Name);
string OutputFile = System.IO.Path.Combine("H:/Bloq1/", "@"+file.Name);
using (Stream input = new FileStream(InputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
{
PdfReader.unethicalreading = true;
PdfReader reader = new PdfReader(input);
PdfEncryptor.Encrypt(reader, output, true, null, Password, PdfWriter.AllowPrinting);
}
}
file.Delete();
File.Move(@"H:\Bloq1\@"+file.Name, @"H:\Bloq1\"+file.Name);
tbx.Text = "Full Protected";
tbx.Background = Brushes.ForestGreen;
}
catch (Exception ex)
{
tbx.Text = "Error in: " + file.Name + ex;
tbx.Background = Brushes.IndianRed;
}
}
}
}
Возможная Дубликат [Страница усечение в правой части при альбомной ориентации с использованием trimmargins PDFsharp] (http://stackoverflow.com/questions/10948731/page-truncate-in-right-side-for-landscape- Ориентация-с-trimmargins-using-pdf) –
В сообщении, которое вы связываете, это рендеринг нового pdf. Я пытаюсь защитить существующий, спасибо за чтение. – Kuri