PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Apr 24, 2024 9:44 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Tue Feb 27, 2024 2:25 pm 
Offline

Joined: Tue Feb 27, 2024 1:21 pm
Posts: 5
According to the README file, regarding changes to version 6.0,
Quote:
Assets are removed from repositories
PDFsharp uses a lot of assets like files for images, fonts, or PDFs. Starting with PDFsharp 6 these assets are not part of the repositories anymore. Instead they are available for download from https://assets.pdfsharp.com. Before you can compile or run projects of a solution go to the dev folder in the solution root and run download-assets.ps1 once. This script downloads the assets required by the solution from the web in to the assets folder.


I would imagine the reason for this has to do with not having the rights to distribute the assets. I attempted to use the powershell script to download the assets, but to no avail. I think I found the reason why:
From the website https://docs.pdfsharp.net/General/Overview/Repositories.html, I get the following:
Quote:
PDFsharp has the following repositories
Repository GitHub Description
PDFsharp yes Contains PDFsharp and MigraDoc foundation source code.
PDFsharp.Samples yes Contains PDFsharp and MigraDoc examples.
PDFsharp.Lab not yet Contains PDFsharp and MigraDoc sample code and test apps that may be useful for developers.
PDFsharp.IssueSubmissionTemplate yes Contains minimal PDFsharp and MigraDoc sample apps for all three builds (Core, GDI, and WPF) for submitting issues.
PDFsharp.Assets no Contains the assets that are published as an Azure static web app at https://assets.pdfsharp.net. [iThis repo is not public available.[/i]
PDFsharp.Tests no Contains tests based on resources, documents, fonts etc. that comes from our customers. This repo is not public available. It is mentioned here to illustrate that we have more test code than that in the PDFsharp repo.
PDFsharp.Docs not yet Contains the DocFx source markdown of this web site. This repo is currently not yet publicly available.


The repository of assets is not publicly available, which would be why the powershell script failed to download them. So, how is the average user like me supposed to get the assets?


Last edited by agerber85 on Wed Feb 28, 2024 6:20 pm, edited 4 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 27, 2024 2:32 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
agerber85 wrote:
So, how is the average user like me supposed to get the assets?
The answer is in the text you quoted: Run the script "download-assets.ps1" in the "dev" folder of the repository.

The script works for me. It only accesses public files from the Assets site.
Which error messages do you get?

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 27, 2024 2:46 pm 
Offline

Joined: Tue Feb 27, 2024 1:21 pm
Posts: 5
TH-Soft wrote:
agerber85 wrote:
So, how is the average user like me supposed to get the assets?
The answer is in the text you quoted: Run the script "download-assets.ps1" in the "dev" folder of the repository.

The script works for me. It only accesses public files from the Assets site.
Which error messages do you get?

I didn't get any error messages, but the assets folder was empty after running the script.

Lest you should think I failed to point to the correct output directory, here's how I modified the powershell script:
Code:
# Downloads assets

#Requires -Version 7
#Requires -PSEdition Core

# Get-ChildItem .\ -include bin,obj -Recurse | ForEach-Object ($_) { remove-item $_.fullname -Force -Recurse }

[string[]]$assetList = @(
    "pdfsharp/pdfsharp.zip"
    "migradoc/migradoc.zip"
    "pdfsharp-6.x/pdfsharp-6.x.zip"
    # Grammar by example archive => Move to PDFsharp.Lab
    "archives/grammar-by-example/GBE.zip"
    "archives/samples-1.5/samples-1.5.zip"
)

$source = "https://assets.pdfsharp.net/"
$destination = "$PSScriptRoot/assets/" #This is the directory where I found no assets after running the script.

if (test-path -PathType container $destination) {
    Remove-Item -LiteralPath $destination -Force -Recurse
}
New-Item -ItemType Directory -Path $destination

foreach ($asset in $assetList) {
    $url = $source + $asset
    $dest = $destination + $asset

    $folder = [IO.Path]::GetDirectoryName($dest)
    New-Item -ItemType Directory -Path $folder -Force

    $x = Invoke-WebRequest $url -OutFile $dest

    $idx = $asset.LastIndexOf("/")
    $assetFolder = $asset.Substring(0, $idx)
    $zip = $asset.Substring($idx + 1)
    Expand-Archive "$destination/$asset" -DestinationPath "$destination/$assetFolder" -Force
    if ($LASTEXITCODE -eq 0) {
        Remove-Item "$destination/$asset"
        # Not all ZIP files contain compress.ps1. Suppress error messages.
        Remove-Item "$destination/$assetFolder/compress.ps1" -ErrorAction Ignore
    }
}


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 27, 2024 3:18 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
agerber85 wrote:
Lest you should think I failed to point to the correct output directory, here's how I modified the powershell script:
I don't want to check the differences.

The original version works on our computers.

Your code will download the assets into an "assets" folder under the "dev" folder where the projects will not find them - unless you moved the script file to a different folder.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 28, 2024 4:32 pm 
Offline

Joined: Tue Feb 27, 2024 1:21 pm
Posts: 5
Thanks for your patience. Unfortunately, I cannot run the script, as my system keeps saying I only have PowerShell 5.1. All attempts to upgrade to 7 have failed.

These attempts included using winget to install from msstore and winget sources and downloading PowerShell-7.4.1-win-x64.zip from https://github.com/PowerShell/PowerShell/releases and unzipping it into Program Files and adding it to the system path variable. Running `PowerShell -version 7` still returns an error that version 7 is not installed.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 28, 2024 6:23 pm 
Offline

Joined: Tue Feb 27, 2024 1:21 pm
Posts: 5
I'm no longer struggling with getting the assets downloaded! After running PowerShell-7.4.1-win-x64.msi from https://learn.microsoft.com/en-us/power ... rshell-7.4, I had a separate start menu entry for PS7. Running that as admin, I was able to run the download script.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 28, 2024 7:09 pm 
Offline

Joined: Tue Feb 27, 2024 1:21 pm
Posts: 5
Apologies to any who were involved in my struggle to download assets for PDFsharp 6.0 for my being so needy. I have the assets downloaded, but I'm not sure where they need to be placed. The script looks to me like it should place the downloaded files in a directory called "assets" that shares a parent directory with the directory from which the script is launched. However, I don't know what directory should have been the launch directory.

A little context for why I'm so confused: I'm one of those weirdos that don't clone the entire repository and build it, but rather want to install PDFsharp from the NuGet Package Manager.


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 29, 2024 8:00 am 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 340
agerber85 wrote:
Apologies to any who were involved in my struggle to download assets for PDFsharp 6.0 for my being so needy. I have the assets downloaded, but I'm not sure where they need to be placed. The script looks to me like it should place the downloaded files in a directory called "assets" that shares a parent directory with the directory from which the script is launched. However, I don't know what directory should have been the launch directory.
The script is in the "/dev" folder of the repository and downloads assets into the "/assets" folder of the repository.
Assets can be anywhere, but that requires code changes.

agerber85 wrote:
A little context for why I'm so confused: I'm one of those weirdos that don't clone the entire repository and build it, but rather want to install PDFsharp from the NuGet Package Manager.
You don't need the assets if you use the repository only to inspect the source code.
The packages are on NuGet.org.

_________________
Ă–hmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 29, 2024 9:20 pm 
Offline

Joined: Thu Feb 29, 2024 8:55 pm
Posts: 2
Hi, I hand the same issues as you just recently. Happy to know it's not only me :)
I will share what I've figured out if there are more people and in case I will forget.

The PowerShell 7 will not replace the PS5. By default you need to used different name to start it.
After installing the PS7 you should run the script without any issues by doing this (assuming you use VS2022):
1. In solution explorer swich to Folder View and make sure Show All Files button is ON.
2. You should see folder named .vs
3. Create a file named task.vs.json in this folder and put following content in it:
Code:
{
  "version": "2.0.0",
  "tasks": [
    {
      "taskLabel": "Script",
      "command": "pwsh.exe",
      "appliesTo": "*.ps1",
      "args": [
        "-ExecutionPolicy",
        "Bypass",
        "-File",
        "${file}"
      ]
    }
  ]
}

4. After saving the file, you should see a Run Script item showing up if you invoke context menu on any .ps1

Quote:
You don't need the assets if you use the repository only to inspect the source code.

If you would write this on the page you wouldn't have to explain things on the forum, and we would also save some time.


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 29, 2024 9:54 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
Audionysos wrote:
Quote:
You don't need the assets if you use the repository only to inspect the source code.

If you would write this on the page you wouldn't have to explain things on the forum, and we would also save some time.
I don't think so.
Questions from the FAQ appear frequently on the forum.

It's obvious that you only need the repository from GitHub to look at the source code.

The .PS1 file shows an error message when a PowerShell version earlier than 7.0 is used.
It's obvious that you may not have time to see the error message when double-clicking a .PS1 file in Windows Explorer.

It's obvious that .PS1 files may no longer work when one makes changes without understanding their purpose.

I'll see which improvements can be made to the site with respect to information about downloading the assets.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 01, 2024 12:09 am 
Offline

Joined: Thu Feb 29, 2024 8:55 pm
Posts: 2
TH-Soft wrote:
It's obvious that you only need the repository from GitHub to look at the source code.


Maybe it's obvious to a creator of a specific repository.
How do I know the are no code files generated at build that depend on "Assets"? It' quite vague term.
And the main readme.md clearly states that:
Quote:
You must download them before compiling the solution for the first time.


_____________________________

TH-Soft wrote:
Questions from the FAQ appear frequently on the forum.


Nice to know you have a FAQ... yhm... were is that?
Sorry if this will sound like complaining but I'm a bit confused... You have like 4? different web pages, puls a forum and the repository. All those pages look like completely different projects... And just now, after reading some other recent topis, I found out there is a separate PDFSharpCore project which is not the same as what you refer to as PDFsharp Core, which mad me questioning my library pick again...

I've started trying some PDF libs just last week, they all are not very intuitive (like iText API looks horrible), I've decided to give PDFShap a closer look as it seem to be giving access to a low level stuff. I spend like an hour in search for the "PDP Explorer" app(that you mention on at least two pages), in hope it will help me understand the file structure, but didn't succeeded in that. The only few answers on SO I've found produced garbage result... I'm in the middle of reading a 1000 pages of recent PDF ISO spec (actually in parallel with reading spec for PDF1.0 because it's less mouthful and I found it's much easier to understand core concepts) and playing with the code, I use practically all my spare time on this and not really sure how long it will took me...
All this just because I want to read a simple (10 yo) document with plain text and few basic formatting, so yes, I may be a bit frustrated, sorry again...


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 01, 2024 10:30 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
Audionysos wrote:
How do I know the are no code files generated at build that depend on "Assets"?
You need the assets to compile the repository.
You do not need them to study the source code from the repository.

You do not need them (assets and repository) to use PDFsharp as we offer NuGet packages.

PdfSharpCore is a partial port of PdfSharp.Xamarin which in turn is a partial port of PDFsharp 1.x.
I cannot tell you which version is better. Font handling and image handling are different.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 175 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group